angular.module('app.filters', [])
	.filter('toAge', function() {
		//calculate the driver's valid driving age.
		return function(date) {
			return new Date().getYear() - new Date(date).getYear();
		}
	})
	.filter('toDate', function () {
		return function (date) {
			return moment(new Date(date)).format('YYYY-MM-DD');
		}
	})
	.filter('percentage', ['$filter', function ($filter) {
  return function (input, decimals) {
    return $filter('number')(input , 2) + '%';
  };
}])
	.filter('monthName', [function() {
    return function (monthNumber) { //1 = January
        var monthNames = [ 'January', 'February', 'March', 'April', 'May', 'June',
            'July', 'August', 'September', 'October', 'November', 'December' ];
        return monthNames[monthNumber - 1];
    }
}]);